package com.nulldev.util.VariableAPI.util.random.fasterrng;

import java.util.Random;

import com.nulldev.util.data.Variables;

public class FasterRandomAdapter extends Random {

	private static final long serialVersionUID = 3627151878486368039L;

	private final FasterRandom fr;

	public FasterRandomAdapter(final FasterRandom fr) {
		this.fr = Variables.requireNonNullObject(fr, "fr");
	}

	@Override
	public int nextInt() {
		return this.fr.nextInt();
	}

	@Override
	public int nextInt(final int bound) {
		return this.fr.nextInt(bound);
	}

	@Override
	public boolean nextBoolean() {
		return this.fr.nextBoolean();
	}

	@Override
	public void nextBytes(final byte[] bytes) {
		this.fr.nextBytes(bytes);
	}

	@Override
	public double nextDouble() {
		return this.fr.nextDouble();
	}

	@Override
	public synchronized double nextGaussian() {
		return this.fr.nextGaussian();
	}

	public byte[] bytes(final int length) {
		if (length <= 0)
			throw new IllegalArgumentException("length <= 0!");
		final byte[] arr = new byte[length];
		this.fr.nextBytes(arr);
		return arr;
	}

	@Override
	public float nextFloat() {
		return this.fr.nextFloat();
	}

	@Override
	public long nextLong() {
		return this.fr.nextLong();
	}

	@Override
	public synchronized void setSeed(final long seed) {
		if (this.fr != null)
			this.fr.setSeed(seed);
	}
}
